<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>华猫商城</title>
		<style></style>
		<link href="../css/common.css" rel="stylesheet">
		<link href="../css/base.css" rel="stylesheet">
		<link rel="stylesheet" href="css/carts.css" />
		<style>
			body {
				background-color: #f5f5f5;
			}
			/*不显示搜索框*/
			
			.ZZHT-search-box {
				display: none;
			}
		</style>
	</head>

	<body>
		<div id="header"></div>
		<div id="headerBox"></div>
		<!--<div id="nav_menu"></div>-->
		<div class="black_line"></div>
		<div class="ZZHT-container" style="margin-top:50px;margin-bottom:50px;">
			<div class="ZZHT-clear"></div>
			<div class="order_cash_box">
				<div class="title">收银台</div>
				<div class="total_price">¥<span class="money">10</span></div>
				<div class="tab_slide">
					<div class="tab_menu">
						<!--<a href="#none" class="current">现金账户</a>-->
						<!--<a href="#none">华宝</a>
						<a href="#none">微信</a>
						<a href="#none">支付宝</a>
						<a href="#none">快捷支付</a>
						<a href="#none">网关支付</a>-->
						<a v-for="(m,i) in payArr" :class="m.name" style="display: none;" :href='m.url+pathParam'>
							{{m.val}}
						</a>
					</div>
					<div class="tab_cont">
						<!-- 现金金额  -->
						<div class="tab_item">
							<form name="formSubmit" class="cash_form">
								<div class="form-group">
									<label class="control-label"><span class="text-label">现金账户金额：</span><span class="form_price"><span class="ZZHT-fred">&nbsp;¥&nbsp;</span><span class="yue"></span></span></label>
								</div>
								<div class="form-group">
									<label class="control-label"><span class="text-label">本次扣款：</span><span class="form_price"><span class="ZZHT-fred">&nbsp;¥&nbsp;</span><span class="money"></span></span></label>
								</div>
								<div class="form-group">
									<label class="control-label"><span class="text-label">交易密码：</span>
                                    <input class="ipt" type="password" id="payPwd" name="payPwd" onfocus="this.type='password'" maxlength="6" fruit="true" autocomplete="off" onkeydown="if(event.keyCode==13) return false;">
                                    <a class="ZZHT-f999" href="../Usercenter/7-1.html" style="margin-left: 15px;font-size: 12px;">忘记密码？</a>
                                </label>
								</div>
								<div class="form-group">
									<input class="subMitButton sure_btn" id="payCash" type="button" value="确认" onkeydown="if(event.keyCode==13) return false;">
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div id="ck1"></div>
		<div id="ck3"></div>
		<script src="../js/jquery.min.js"></script>
		<script src="../js/vue.min.js"></script>
		<script type="text/javascript" src="../js/qrcode.js"></script>
		<script type="text/javascript" src="../plugin/layer/layer.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/common_view.js"></script>
		<script type="text/javascript" src="../js/ljf_base.js"></script>
		<script type="text/javascript" src="js/carts.js"></script>

		<script src="../js/lxs_jk.js" type="text/javascript" charset="utf-8"></script>

		<script type="text/javascript">
			var path = ''; //不同的支付接口
			var payType = [];
			if(gup('path')) {
				path = gup('path');
			}
			
			var orderId = gup('orderId');
			var money = gup('money');
			$('.money').html(money);

			var vm = new Vue({ //new 一个实例
				el: '.ZZHT-container', //作用域 父及的id 我这里放到了整个内容区
				data: { //数据源
					cart: [],
					pathParam:'',
					payArr: [
						{
							img: 'img/xj.png',
							name: 'type_2 current',
							val:'现金账户',
							url:'checkout_grade.html',
						},
						{
							img: 'img/hb.png',
							name: 'type_3',
							val:'华宝',
							url:'checkout_grade_hb.html',
						},
//						{
//							img: 'img/wx.png',
//							name: 'type_4',
//							val:'微信',
//						},
//						{
//							img: 'img/alipay.png',
//							name: 'type_4',
//							val:'支付宝',
//						},
//						{
//							img: 'img/kj.png',
//							name: 'type_4',
//							val:'快捷支付',
//						},
//						{
//							img: 'img/wg.png',
//							name: 'type_4',
//							val:'网关支付',
//						},
						{
							img: '',
							name: 'type_1',
							val:'线下支付',
							url:'underLinePay.html',
						},
						{
							img: '',
							name: 'type_6',
							val:'华宝营业额',
							url:'checkout_grade_hbhk.html',
						},
					]
				},
				methods: {

				}
			});

			$(function() {
				vm.pathParam = '?'+window.location.href.split('?')[1];
				
				if(localStorage.payData){
					var payData = JSON.parse(localStorage.payData);
					var typeList = payData.allowPayType.split(',');
					$.each(typeList, function(i, v) {
						$('.type_' + v).show();
					})
				}
				
				$.ajax({ //获取用户余额
					type: "get",
					url: SURL + "webAccount/getAccount",
					data: {
						userId: localStorage.userId,
					},
					success: function(data) {
						console.log(data);
						$('.yue').html(data.entity.cash);
					}
				});

				$('#payCash').click(function() {
					
					if(parseFloat(money) > parseFloat($('.yue').html())) {
						layer.msg('余额不足，请充值');
					} else if(!$('#payPwd').val()) {
						layer.msg('请输入支付密码');
					} else {
						var url = path || 'webAccount/toUpPay';
						var data = {};
						
						data.userId = localStorage.userId;
						data.orderId = orderId;
						data.realMoney = 0;
						data.cash = 0;
						data.kaiyuan = 0;
						data.kaiyuanFee = 0;
						data.payPwd = $('#payPwd').val();
						data.cash = money;
						data.payType = 2;
						
						if(url == 'webAccount/toUpPay') { //用户升级支付
							var backTo = '../Usercenter/01.html';
						} else if(url == 'webAccount/buyStockScoreAfter') { //申请库存积分支付
							var backTo = '../underLineShop/01.html';
						}else if(url == 'sktBuyplaque/enterBuyplaque') { //购买牌匾支付
							var backTo = '../underLineShop/58.html';
						}
						
						$("#payCash").val('正在支付...').attr('disabled', true);
						$.ajax({ //
							type: "get",
							url: SURL + url,
							data: data,
							async: false,
							success: function(data) {
								console.log(data);
								if(data.entity.code == '01') {
									layer.msg('支付成功', {
										icon: 6
									}, function() {
										window.location.href = backTo;
									});
								} else {
									layer.msg(data.entity.msg);
									$("#payCash").val('确定').attr('disabled', false);
								}
							}
						});
					}

				})
			})
		</script>
	</body>

</html>